import { createApp } from 'vue'
import './style.css'
import App from './App.vue'

import router from "./router"

import ElementPlus, { ElMention } from "element-plus"
import 'element-plus/theme-chalk/index.css'

import * as ElementPlusIconsVue from "@element-plus/icons-vue"

// import { createPinia } from 'pinia'
import piniaInstance from '../src/store/index'
// import PiniaPluginPersistedState from "pinia-plugin-persistedstate"
// import { useFactory } from './utils/factory'

import '@imengyu/vue3-context-menu/lib/vue3-context-menu.css'
import ContextMenu from '@imengyu/vue3-context-menu'
import { useGlobalState } from './store/globalState'

import { NMessageProvider, NNotificationProvider } from 'naive-ui'

const app = createApp(App)

// const piniaInstance = createPinia().use(PiniaPluginPersistedState)
// const piniaInstance = pinia.use(PiniaPluginPersistedState);


for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
// 引入组件库的少量全局样式变量
import 'tdesign-vue-next/es/style/index.css';


// app.use(piniaInstance)      // 先挂载pinia，确保不影响后面使用
app.use(piniaInstance)
app.use(router)
app.use(ElementPlus)
app.use(ContextMenu)

// 动态加载所有的pinia store

// 关闭vue的所有警告
app.config.warnHandler = () => {
    // 什么都不做，相当于忽略了所有警告
}


app.mount('#app');



useGlobalState().setAppMounted(true);




